<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        $tiezi_cat=$_REQUEST['tiezi_cat'];
        $bt=$_REQUEST['bt'];
        $content=$_REQUEST['content'];
        $img_list=$_REQUEST['img_list'];
        $time=date('Y-m-d H:i:s');
        $sql="select isForum from `".$oto."_users` where `userId`='{$user_id}' and userFlag='1'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($user_info))
		{
			if($user_info[0]['isForum']==0)
			{
				$data[0]['pan']="-1";
				$data[0]['msg']="没有权限发帖子";
				echo json_encode($data);
				die();
			}
		}
		$sql="select * from `".$oto."_posts_cate` where `name`='{$tiezi_cat}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$posts_cate[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$cid=0;
		if(isset($posts_cate))
		{
			$cid=$posts_cate[0]['cid'];
		}
		$sql="INSERT INTO ".$oto."_posts (`cid`,`title`,`content`,`userId`,`ftime`,`status`,`img`) VALUES ('$cid','$bt','$content','$user_id','$time','1','$img_list')";
        $result=$db->query($sql);
        if($result)
        {
        	$data[0]['pan']="true";
        }
        else $data[0]['pan']="false";
		echo json_encode($data);
?>